<?php

/*
  VoIP Wholesale 1.0
  ------------------
  Document   : module_origin_edit
  Created on : Nov 29, 2011, 4:29:10 PM
  Author     : Milos Jovanovic <miloscode@gmail.com>
  Description:

 */
?>
<div id="page-title"><?=$trunk['short_name']?></div>

<div id="page-desc"></div>

<div class="ui-widget"> 
    <div id="content">      
        <fieldset>
        <!-- PAGE CONTENT -->
	<form action="" method="post" id="edit-trunk" onsubmit="return false;"> 
		<fieldset class="ui-widget-content ui-corner-all">
		<legend class="ui-widget-content ui-corner-all"><?=lang('text_trunk_information')?></legend>
				<p>
					<label><?=lang('term_carrier')?></label> 
					<?php 
					$carrier = $this->PACKAGE->routing->carriers->get_carrier_as_array_by_id($trunk['carrier_id']); 					
					?>
					<input type="text" value="<?=$carrier['username']?>" class="text ui-state-disabled ui-widget-content ui-corner-all deactivated"/>
                </p>
				<p>
					<label><?=lang('term_short_name')?></label> 
					<input type="text" name="data[short_name]" id="short_name" value="<?=$trunk['short_name']?>" class="text ui-state-disabled text ui-widget-content ui-corner-all" /> 					
                </p>
				<p class="cli"> 
					<span class="I">
							<input type="radio" name="data[cli_guaranteed]" value="1" <?php if($trunk['cli_guaranteed']){?>checked="checked"<?php }?>/>
					</span>
					<span class="II">
							<label><?=lang('term_cli_guaranteed')?></label>
					</span>
					<span class="III">
							<input type="radio" name="data[cli_guaranteed]" value="0" <?php if(!$trunk['cli_guaranteed']){?>checked="checked"<?php }?>/>
					</span>
					<span class="IV">
							<label><?=lang('term_cli_not_guaranteed')?></label>
					</span>
				</p>				
				<p>
					<label><?=lang('term_description')?></label> 
					<textarea name="data[description]" class="ui-widget-content module-textarea"><?=$trunk['description']?></textarea>
				</p>
			</fieldset>
		<fieldset class="ui-widget-content ui-corner-all">
		<legend class="ui-widget-content ui-corner-all"><?=lang('text_codecs')?></legend>			
				<p>
					<div class="codecs">
					
						<?php $trunk_codecs = $this->APPLICATION->app_trunks->get_trunk_codecs($trunk['id'],'termination');?>
					
						<?=$this->APPLICATION->app_codecs->generate_menu("codecs",$trunk_codecs,"module-codec")?>
					</div>
                </p>	
		</fieldset>
		<fieldset class="ui-widget-content ui-corner-all">
		<legend class="ui-widget-content ui-corner-all"><?=lang('text_access_parameters')?></legend>			
				<p>
					<div class="access">
					
					<a href="javascript:void(0);" onclick="show_hide_ips(this)" class="show-hidden-ips-link">[<?=lang('link_show_hidden_ips')?>]</a><br />
					
								<span class="ip_address">
								<?=lang('term_ip_address')?>
								</span>
								<span class="tech_prefix">
								<?=lang('term_tech_prefix')?>
								</span>								
								<br />
								
						<div class="rows-container">						
						
						<script type="text/javascript">
							var row_number = 0;
						</script>
						<?php $ip_addresses = $this->APPLICATION->app_trunks->get_trunk_ip_addresses($trunk['id'],'termination','all');?>
						
						<?php 
						if(is_array($ip_addresses)){
						foreach($ip_addresses as $entry){?>
							<div class="row1 <?php if(!$entry['status']){?>ui-state-disabled  hidden-ip<?php } else{?>ui-state-active<?php }?> ip_address_<?=$entry['id']?> ui-widget-content ui-corner-all">
								<span class="ip"><?=$entry['ip_address']?></span>
								<span class="tech"><?=$entry['tech_prefix']?></span>
								<?php if($entry['status']){?>
								<a href="javascript:void(0);" onclick="disable_ip_address_dialog(this);" class="button ui-state-default ui-corner-all" rel="<?=$entry['id']?>" title="<?=lang('term_disable')?>"><span class="ui-icon ui-icon-circle-minus"></span><?=lang('term_disable')?></a>
								<?php }?>
							</div>
						<?php }}?>
							<br /><br />
							<div class="row ui-state-default ui-corner-all" id="row_0">
								<input type="hidden" name="data[parameters][]" value="0"/>
								<input type="text" name="data[ip_address_segment_1][]" class="address text ui-widget-content ui-corner-all" maxlength="3"/> . 
								<input type="text" name="data[ip_address_segment_2][]" class="address text ui-widget-content ui-corner-all"  maxlength="3"/> . 
								<input type="text" name="data[ip_address_segment_3][]" class="address text ui-widget-content ui-corner-all"  maxlength="3"/> . 
								<input type="text" name="data[ip_address_segment_4][]" class="address text ui-widget-content ui-corner-all"  maxlength="3"/>
								<input type="text" name="data[tech_prefixes][]" class="prefix_field text ui-widget-content ui-corner-all"/>								
								<a href="javascript:void(0);" onclick="delete_row(this);" class="button delete ui-state-default ui-corner-all" title="<?=lang('term_delete')?>"><span class="ui-icon ui-icon-circle-close"></span><?=lang('term_delete')?></a>
							</div>
							
						</div>
								
								<br />
								<a href="#" onclick="add_new_row(this);" class="button ui-state-default ui-corner-all" title="<?=lang('term_add_new_row')?>"><span class="ui-icon ui-icon-circle-close"></span><text><?=lang('term_add_new_row')?></text></a>
					</div>
                </p>	
		</fieldset>		
				<p>
					<input type="hidden" name="data[confirm]" id="confirm" value="false"/>
					<script type="text/javascript">
						var trunk_ID = "<?=$trunk['id']?>";
					</script>					
					<div id="response"></div><br />
					<button id="module-edit-termination-trunk"><?=lang('button_save')?></button>
				</p>
	 </form> 

	 </div>    
</div>   

						<p class="sample-row">
								<a href="javascript:void(0);" onclick="delete_row(this);" class="button delete ui-state-default ui-corner-all" title="<?=lang('term_delete')?>"><span class="ui-icon ui-icon-circle-close"></span><?=lang('term_delete')?></a>
						</p>	
						<div id="disable-ip-address">
							<p>
								<?=lang('text_are_you_sure_you_want_to_disable_ip_address')?>? <br /><br />
								<?=lang('text_this_happens_instantly')?>
							</p>
						</div>						
